package com.dg11185.nearshop.net.request;

import com.dg11185.libs.utils.MD5.MD5Utils;
import com.dg11185.nearshop.app.Constants;
import com.dg11185.nearshop.net.HttpCacheRequest;
import com.dg11185.nearshop.net.response.GetMerchantListResponse;

/**
 * 
 * @author：Daibo    
 * @time：2014-5-16 下午1:32:07
 */
public class GetMerchantListRequest extends HttpCacheRequest<GetMerchantListResponse>{

    public final String INDUSTRY_ID = "industryId";
    public final String AREA_ID = "businessAreaId";
    public final String BRAND_ID = "brandId";
    public final String MERCHANT_NAME = "merchantName";
    public final String LONGITUDE = "longitude";
    public final String LATITUDE = "latitude";
    public final String RADIUS = "radius";
    public final String PAGE_NUM = "pageNumber";
    public final String PAGE_SIZE = "pageSize";
    public final String ORDER_NAME = "orderName";
    public final String ORDER_TYPE = "orderType";
    
    public GetMerchantListRequest(String areaNum) {
        super(Constants.ADDRESS, Constants.getMerchantList);
        addParam("areaNum", areaNum);
        setIsCreateFloder(true);
    }

    /**
     * <可选参数>
     * <param name="industryId">行业编号</param>
     * <param name="businessAreaId">商圈编号</param>
     * <param name="brandId">品牌编号</param>
     * <param name="merchantName">商家名称</param>
     * <param name="longitude">经度</param>
     * <param name="latitude">纬度</param>
     * <param name="radius">半径</param>
     * <param name="pageNumber">当前页码</param>
     * <param name="pageSize">每页数量</param>
     * <param name="orderName">排序字段</param>
     * <param name="orderType">0.升序，1.降序</param>
     * </可选参数>
     */
    public GetMerchantListRequest add(String key, String value){
        addParam(key, value);
        return this;
    }
    
    public GetMerchantListRequest encryption(){
        addParam("chshToken", Constants.TOKEN);
        addParam("chshSign", MD5Utils.getMD5Str(getParams(), Constants.MD5_key));
        return this;
    }
    
    @Override
    protected GetMerchantListResponse parseJson(String response) throws Exception {
        GetMerchantListResponse r = new GetMerchantListResponse();
        r.parseJson(response);
        return r;
    }

}
